<?php

session_start();
include 'db_connect.inc.php';
$verhalten = 0;

if (!isset($_SESSION["username"]) and !isset($_GET["page"])) {
    $verhalten = 0;
}

if ($_GET["page"] == "log") {

    $user = $_POST["user"];
    $passwort = $_POST["passwort"];

    $control = 0;
    $abfrage = "SELECT * FROM quizUser WHERE Email = '$user' AND Vorname = '$passwort'";
    $ergebnis = mysql_query($abfrage);
    while ($row = mysql_fetch_object($ergebnis)) {
        $control++;
    }
    if ($control != 0) {
        $_SESSION["username"] = $user;
        $verhalten = 1;
        $_SESSION["Punkte"] = 0;

    } else {
        $verhalten = 2;
    }
}
?>
